<!DOCTYPE html>
<html>

	<head lang="en">
		<meta charset="UTF-8">
		<title>注册</title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<meta name="format-detection" content="telephone=no">
		<meta name="renderer" content="webkit">
		<meta http-equiv="Cache-Control" content="no-siteapp" />

		<!-- 引入nginx服务器地址，会将该地址拼接在所在静态资源的路径前面 -->
<!--		<base href="http://192.168.20.166:80/"/>-->

		<link rel="stylesheet" href="/AmazeUI-2.4.2/assets/css/amazeui.min.css" />
		<link href="/css/dlstyle.css" rel="stylesheet" type="text/css">
		<script src="/AmazeUI-2.4.2/assets/js/jquery.min.js"></script>
		<script src="/AmazeUI-2.4.2/assets/js/amazeui.min.js"></script>

	</head>

	<body>

		<div class="login-boxtitle">
			<a href="/"><img alt="" src="/images/logobig.png" /></a>
		</div>

		<div class="res-banner">
			<div class="res-main">
				<div class="login-banner-bg"><span></span><img src="/images/big.jpg" /></div>
				<div class="login-box">

						<div class="am-tabs" id="doc-my-tabs">
							<ul class="am-tabs-nav am-nav am-nav-tabs am-nav-justify">
								<li class="am-active"><a href="">邮箱注册</a></li>
								<li><a href="">手机号注册</a></li>
							</ul>

							<div class="am-tabs-bd">
								<div class="am-tab-panel am-active">
									<form method="post">
										
							   <div class="user-email">
										<label for="email"><i class="am-icon-envelope-o"></i></label>
										<input type="email" name="email" id="email" placeholder="请输入邮箱账号">
                 </div>										
                 <div class="user-pass">
								    <label for="password"><i class="am-icon-lock"></i></label>
								    <input type="password" name="passwordMail" id="passwordMail" placeholder="设置密码">
                 </div>										
                 <div class="user-pass">
								    <label for="passwordRepeat"><i class="am-icon-lock"></i></label>
								    <input type="password" name="passwordRepeatMail" id="passwordRepeatMail" placeholder="确认密码">
                 </div>	
                 
                 </form>
                 
								 <div class="login-links">
										<label for="reader-me-mail">
											<input id="reader-me-mail" type="checkbox"> 点击表示您同意商城《服务协议》
										</label>
							  	</div>
										<div class="am-cf">
											<input id="mail-reg" type="button" name="" value="注册" class="am-btn am-btn-primary am-btn-sm am-fl">
											<span id="msg1" style="color: red; text-align: center"></span>
										</div>

								</div>

								<div class="am-tab-panel">
									<form method="post">
                 <div class="user-phone">
								    <label for="phone"><i class="am-icon-mobile-phone am-icon-md"></i></label>
								    <input type="tel" name="" id="phone" placeholder="请输入手机号">
                 </div>																			
										<div class="verification">
											<label for="code"><i class="am-icon-code-fork"></i></label>
											<input type="tel" name="" id="code" placeholder="请输入验证码" style="width: 60%">
											<a class="btn" href="javascript:void(0);" onClick="getcode(this);" id="sendMobileCode">
												<span id="dyMobileButton" style="width: 40%">获取</span></a>
										</div>
                 <div class="user-pass">
								    <label for="password"><i class="am-icon-lock"></i></label>
								    <input type="password" name="phonePassword" id="password" placeholder="设置密码">
                 </div>										
                 <div class="user-pass">
								    <label for="passwordRepeat"><i class="am-icon-lock"></i></label>
								    <input type="password" name="" id="passwordRepeat" placeholder="确认密码">
                 </div>	
									</form>
								 <div class="login-links">
										<label for="reader-me-phone">
											<input id="reader-me-phone" type="checkbox"> 点击表示您同意商城《服务协议》
										</label>
							  	</div>
										<div class="am-cf">
											<input id="phoneRegisterBtn" type="button" name="" value="注册" class="am-btn am-btn-primary am-btn-sm am-fl">
											<span id="msg2" style="color: red; text-align: center"></span>
										</div>
								
									<hr>
								</div>

								<script>
									$(function() {
									    $('#doc-my-tabs').tabs();
									  })
								</script>

							</div>
						</div>

				</div>
			</div>
			
					<div class="footer ">
						<div class="footer-hd ">
							<p>
								<a href="# ">恒望科技</a>
								<b>|</b>
								<a href="# ">商城首页</a>
								<b>|</b>
								<a href="# ">支付宝</a>
								<b>|</b>
								<a href="# ">物流</a>
							</p>
						</div>
						<div class="footer-bd ">
							<p>
								<a href="# ">关于恒望</a>
								<a href="# ">合作伙伴</a>
								<a href="# ">联系我们</a>
								<a href="# ">网站地图</a>
								<em>© 2015-2025 Hengwang.com 版权所有</em>
							</p>
						</div>
					</div>
		</div>
	</body>


<script>
	var time = 60;
	function countdown(e){
		if (time == 0) {
			//这里时设置当时间到0的时候重新设置点击事件，并且默认time修改为60
			e.setAttribute("onclick","getcode(this)");
			document.getElementById("dyMobileButton").innerText="获取验证码";
			time = 60;
			clearInterval(t);
		}else{
			//这里是显示时间倒计时的时候点击不生效
			e.setAttribute("onclick", '');
			document.getElementById("dyMobileButton").innerHTML="重新发送"+time;
			time--;
		}
	}
	/**
	 * 发送验证码
	 */
	function getcode(e) {
		//1.获取手机号
		var phone_value = $("#phone").val();
		//var phonenumber = $("#phone");
		var url = "/user/reg/code.action";
		var args = {phone : phone_value};


		if(phone_value == 0){
			$("#msg2").text("请输入手机号码");
		}else{
			if(!(/^1[34578]\d{9}$/.test(phone_value))){
				$("#msg2").text("手机号码有误，请重填");
			}else{
				$.get(url, args, function(data){
					$("#msg2").text(data.data);
				});
				//按照指定的周期（以毫秒计）来调用函数或计算表达式。
				//最好是在ajax请求之后再调用函数
				t = setInterval(function () {
					countdown(e)
				}, 1000);
				//获取验证码成功后调用倒计时函数
				countdown(e);
			}
		}
	}

	/**
	 * 邮箱注册
	 *
	 */
	$("#mail-reg").click(function () {

		var mail = $("#email").val();
		var password = $("#passwordMail").val();
		var passwordRepeatMail = $("#passwordRepeatMail").val();

		if(password==null||passwordRepeatMail==null){
			$("#msg1").text("密码和确认密码不得为空");
		}else if(password==passwordRepeatMail){

			if (/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test( $("#email").val())==false) {
				//不符合邮箱正则
				$("#msg1").text("请检查邮箱");


			}else{

				if($("#reader-me-mail").prop('checked')){
					var user = {
						"mail":mail,
						"password":password
					};

					$.ajax({
						url: '/user/reg/emailregister.action',
						contentType : 'application/json',
						dataType:'json',
						data: JSON.stringify(user),
						type:'post',
						success:function (data) {
							if(data.isSuccess) {
								$("#msg1").text(data.data);
							} else {
								$("#msg1").text(data.data);
							}
						}
					});
				}else{
					//未勾选确定协议
					$("#msg1").text("请查看许可协议");
				}
			}

		}else {
			$("#msg1").text("密码和确认密码要一致");
		}




	});


	/**
	 * 电话注册
	 *
	 */
	$("#phoneRegisterBtn").click(function () {

		var phone = $("#phone").val();
		var code = $("#code").val();
		var password = $("[name=phonePassword]")[0].value;
		var passwordRepeatPhone = $("#passwordRepeat").val();

		if(password==null||passwordRepeatPhone==null){
			$("#msg2").text("密码和确认密码不得为空");
		}else if(password==passwordRepeatPhone){

			if ((/^1[34578]\d{9}$/.test(phone))==false) {
				//不符合手机号正则
				$("#msg2").text("请检查手机号码");


			}else{

				if($("#reader-me-phone").prop('checked')){
					var user = {
						"phone":phone,
						"code":code,
						"password":password
					};

					$.ajax({
						url: '/user/reg/smsregister.action',
						contentType : 'application/json',
						dataType:'json',
						data: JSON.stringify(user),
						type:'post',
						success:function (data) {
							if(data.isSuccess) {
								$("#msg2").text(data.data);
							} else {
								$("#msg2").text(data.data);
							}
						}
					});
				}else{
					//未勾选确定协议
					$("#msg2").text("请查看许可协议");
				}
			}

		}else {
			$("#msg2").text("密码和确认密码要一致");
		}



	});

</script>


</html>